---
title: Charts
description: A collection of different chart components using chart.js
---

<ComponentPreview name="area-chart-demo" />

## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>

<TabsContent value="cli">

```bash
npx solidui-cli@latest add charts
```

</TabsContent>

<TabsContent value="manual">
<Steps>

<Step>Install the following dependencies: </Step>

```bash
pnpm install chart.js
```

<Step>Copy and paste the following code into your project: </Step>

<ComponentSource name="charts" />

</Steps>
</TabsContent>

</Tabs>

## Usage

```tsx
import { LineChart } from "~/components/ui/charts"
```

```tsx
const chartData = {
  labels: ["January", "February", "March", "April", "May"],
  datasets: [
    {
      label: "Sales",
      data: [50, 60, 70, 80, 90],
      fill: true // remove if you want a Line Chart
    }
  ]
}
<LineChart data={chartData} />
```

## Pie Chart

<ComponentPreview name="pie-chart-demo" />

## Bar Chart

<ComponentPreview name="bar-chart-demo" />

## Other charts

You can use all charts provided by [chart.js](https://www.chartjs.org/docs/latest/):

- BarChart
- BubbleChart
- DonutChart
- LineChart
- PieChart
- PolarAreaChart
- RadarChart
- ScatterChart
